var t = getApp();

Page({
    data: {
        activity_id: 0,
        details: null,
        page: 1,
        isLoadMore: !0,
        noMore: !1,
        total_page: 0,
        listData: [],
        activityPosterList: [],
        isViewedPosterList: !1
    },
    onLoad: function(t) {
        t.id && this.setData({
            activity_id: t.id
        }), this._getData();
    },
    _getData: function() {
        var a = this, i = t.getNetAddresss("plugin.customer-increase.frontend.activity.activityMemberRank");
        t._postNetWork({
            url: i,
            data: {
                id: this.data.activity_id
            },
            success: function(i) {
                var e = i.data;
                if (1 != e.result) return t.tips(e.msg);
                a.data.total_page = e.data.last_page, a.data.total_page || (a.data.total_page = 0), 
                a.data.page >= a.data.total_page && a.setData({
                    noMore: !0
                });
                var d = [];
                e.data.data && 0 !== e.data.data.length && (d = e.data.data.slice(0, 6)), a.setData({
                    activityPosterList: d,
                    details: e.data,
                    listData: e.data.data
                });
            }
        });
    },
    loadMore: function() {
        var a = this;
        if (this.data.isLoadMore && (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page))) {
            this.data.page += 1;
            var i = t.getNetAddresss("plugin.customer-increase.frontend.activity.activityMemberRank"), e = {
                page: this.data.page,
                id: this.data.activity_id
            };
            t._postNetWork({
                url: i,
                data: e,
                success: function(t) {
                    var i = t.data;
                    if (a.data.isLoadMore = !0, 1 === i.result) {
                        var e = a.data.listData.concat(i.data.data);
                        a.setData({
                            listData: e
                        }), a.data.page >= a.data.total_page && a.setData({
                            noMore: !0
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
                }
            });
        }
    },
    onReady: function() {},
    gotoInvitation: function() {
        wx.navigateTo({
            url: "/packageF/wxFriendExtend/invitationRecord/invitationRecord?id=" + this.data.activity_id
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        0 == this.data.isViewedPosterList && (this.setData({
            activityPosterList: this.data.listData,
            isViewedPosterList: !0
        }), this.loadMore());
    },
    onShareAppMessage: function() {
        return {
            title: "好友裂变排行榜",
            path: "/packageF/wxFriendExtend/workWxFriendExtend/workWxFriendExtend?id=" + this.data.activity_id
        };
    }
});